//
//  LGBestSellerViewController.m
//  LuxuryGoods
//
//  Created by 纳里健康 on 2018/6/4.
//  Copyright © 2018年 Future. All rights reserved.
//

#import "LGBestSellerViewController.h"
#import "NDPageConfig.h"
#import "NDPageViewController.h"
#import "LGResultListViewController.h"
#import "LGScreenViewController.h"

@interface LGBestSellerViewController ()<NDPageViewControllerDelegate>
{
    NDPageConfig *_config;
    
    NSMutableArray *_classsArray;
    
    UIScrollView *_backScrollView;
}

@end

@implementation LGBestSellerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self makeSubView];
    
    [self makeMenu];
    
}

- (void)makeSubView
{
    self.title = @"精选大热卖";
    
    UIImageView *bannerImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, (SCREEN_WIDTH / 72) * 35)];
    
    bannerImage.image = [UIImage imageNamed:@"3"];

    [self.view addSubview:bannerImage];
}

-(void)makeMenu
{
    _config = [[NDPageConfig alloc]init];
    _config.barBtnWidth = SCREEN_WIDTH/4;
    _config.barViewH = 40;
    _config.nomalColor = TEXT_COLOR_2;
    _config.selectColor = TOPCAIL_COLOR;
    _config.nomalFont = [UIFont systemFontOfSize:15];
    _config.selectFont = [UIFont systemFontOfSize:15];
    _config.lineWidth = SCREEN_WIDTH/4;
    _config.lineHight = 0;
    _config.lineColor = TOPCAIL_COLOR;
    
    _config.showIndentifier = YES;
    _config.backColor = WHITE_COLOR;
    
    _classsArray = @[].mutableCopy;
    
    for (int i = 0; i < 4; i ++) {
        
        LGResultListViewController *resultVC = [[LGResultListViewController alloc] init];

        resultVC.fromType = typeBestSeller;
        
        resultVC.Type = (searchType)i;

        resultVC.index = i;
        
        [_classsArray addObject:resultVC];
    }
    
    //综合 价格  上新  筛选
    NDPageViewController *pageViewController = [[NDPageViewController alloc]initWithClassArray:_classsArray titleArray:@[@"综合",@"价格",@"上新",@"筛选"] config:_config];
    
    pageViewController.delegate = self;
    
    [self addChildViewController:pageViewController];
    pageViewController.view.frame = CGRectMake(0, (SCREEN_WIDTH / 72) * 35, SCREEN_WIDTH, SCREEN_HEIGHT - (SCREEN_WIDTH / 72) * 35);
    [self.view addSubview:pageViewController.view];
}

-(void)pageViewOpenMenuAtIndex:(NSInteger)index
{
    if(index == 1)
    {
        LGResultListViewController *resultVC = _classsArray[index];
        resultVC.Type = priceDowmType;
        [resultVC requestData];
    }
}

-(void)pageViewCloseMenuAtIndex:(NSInteger)index
{
    if(index == 1)
    {
        LGResultListViewController *resultVC = _classsArray[index];
        resultVC.Type = priceupType;
        [resultVC requestData];
    }
}

-(void)pageViewSelectAtIndex:(NSInteger)index
{
    NSLog(@"------- %ld",(long)index);
    if(index == 1)
    {
        _config.openImage = [UIImage imageNamed:@"Up"];
        _config.closeImage = [UIImage imageNamed:@"Down"];
        
    }else
    {
        _config.openImage = [UIImage imageNamed:@""];
        _config.closeImage = [UIImage imageNamed:@""];
    }
    
    if(index == 3)
    {
        LGScreenViewController *screenView = [[LGScreenViewController alloc] init];
        
        screenView.view.frame = self.view.bounds;
        
        [self.view addSubview:screenView.view];
    }
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
